package com.google.android.mypetrol;

import android.app.ListActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MyPetrol extends ListActivity {

	public static final String ITEM_TYPE = "type";
	public static final String ITEM_INDEX = "index";
	
	public static final int MODE_NEW = 0;
	public static final int MODE_MODIFY = 1;
	
	public static final String DATE = "date";
	public static final String TOTAL = "total";
	public static final String PRICE = "price";
	
	String[] mLabels;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		Resources r = getResources();
		mLabels = new String[] { r.getString(R.string.main_list_new),
				r.getString(R.string.main_list_history) };

		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, mLabels));
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		switch(position) {
		case 0:
			Intent intent = new Intent(this, PetrolDetailActivity.class);
			intent.putExtra(ITEM_TYPE, MODE_NEW);
			startActivity(intent);
			break;
		case 1:
			startActivity(new Intent(this, HistoryActivity.class));
			break;
		}
		
	}
}